import request from "@/utils/request";
import { Base } from "./base";
import type { requestTypes } from "./types";
export const Apis = {
  login(data: requestTypes["login"]) {
    return request.post(Base.login, data);
  },
  getAllPostItems(data: requestTypes["getAllPostItems"]) {
    return request.post(Base.getAllPostItems, data);
  },
  register(data: requestTypes["register"]) {
    return request.post(Base.register, data);
  },
  getPostListByUserId(data: requestTypes["getPostListByUserId"]) {
    return request.post(Base.getPostItemByUserId, data);
  },
  getPostDetail(params: requestTypes["getPostDetail"]) {
    return request.get(Base.getPostItemById, { params });
  },
  updatePostStatus(data: requestTypes["updatePostStatu"]) {
    return request.post(Base.updatePostItemStatu, data);
  },
  deletePostItem(params: requestTypes["handleDeletePost"]) {
    return request.delete(Base.deletePostItemById, { params });
  },
  getPostItemsCount() {
    return request.get(Base.getPostItemsCount);
  },
  getAllUsers(params: requestTypes["getAllUsers"]) {
    return request.get(Base.getAllUsers, { params });
  },
  changeRole(data: requestTypes["changeRole"]) {
    return request.post(Base.editUserRole, data);
  },
  getPostComments(params: requestTypes["getPostComments"]) {
    return request.get(Base.getCommentsByPostId, { params });
  },
  getChidrenComments(params: requestTypes["getChidrenComments"]) {
    return request.get(Base.getCommentsByCommentId, { params });
  },
  createComment(data: requestTypes["createComment"]) {
    return request.post(Base.createComment, data);
  }
};
